# -*- coding: utf-8 -*-
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models


class Migration(SchemaMigration):

    def forwards(self, orm):
        # Adding model 'RumorVerification'
        db.create_table(u'companies_rumorverification', (
            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('date', self.gf('django.db.models.fields.DateField')(db_index=True)),
            ('stock', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['basic_info.Stock'])),
            ('question', self.gf('django.db.models.fields.TextField')()),
            ('answer', self.gf('django.db.models.fields.TextField')()),
            ('url', self.gf('django.db.models.fields.URLField')(max_length=200)),
        ))
        db.send_create_signal(u'companies', ['RumorVerification'])

        # Adding unique constraint on 'RumorVerification', fields ['date', 'url']
        db.create_unique(u'companies_rumorverification', ['date', 'url'])

        # Adding model 'DailyMoneyFlow'
        db.create_table(u'companies_dailymoneyflow', (
            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('date', self.gf('django.db.models.fields.DateField')(db_index=True)),
            ('stock', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['basic_info.Stock'])),
            ('closed_price', self.gf('django.db.models.fields.FloatField')()),
            ('total_flow', self.gf('django.db.models.fields.FloatField')(db_index=True)),
            ('super_flow', self.gf('django.db.models.fields.FloatField')()),
            ('big_flow', self.gf('django.db.models.fields.FloatField')()),
            ('non_big_flow', self.gf('django.db.models.fields.FloatField')()),
        ))
        db.send_create_signal(u'companies', ['DailyMoneyFlow'])

        # Adding unique constraint on 'DailyMoneyFlow', fields ['date', 'stock']
        db.create_unique(u'companies_dailymoneyflow', ['date', 'stock_id'])

        # Adding model 'DailyMoneyFlowByIndustry'
        db.create_table(u'companies_dailymoneyflowbyindustry', (
            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('date', self.gf('django.db.models.fields.DateField')(db_index=True)),
            ('industry', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['basic_info.Industry'])),
            ('total_flow', self.gf('django.db.models.fields.FloatField')(db_index=True)),
        ))
        db.send_create_signal(u'companies', ['DailyMoneyFlowByIndustry'])

        # Adding unique constraint on 'DailyMoneyFlowByIndustry', fields ['date', 'industry']
        db.create_unique(u'companies_dailymoneyflowbyindustry', ['date', 'industry_id'])

        # Adding model 'DailyMoneyFlowByConcept'
        db.create_table(u'companies_dailymoneyflowbyconcept', (
            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('date', self.gf('django.db.models.fields.DateField')(db_index=True)),
            ('concept', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['basic_info.Concept'])),
            ('total_flow', self.gf('django.db.models.fields.FloatField')(db_index=True)),
        ))
        db.send_create_signal(u'companies', ['DailyMoneyFlowByConcept'])

        # Adding unique constraint on 'DailyMoneyFlowByConcept', fields ['date', 'concept']
        db.create_unique(u'companies_dailymoneyflowbyconcept', ['date', 'concept_id'])

        # Adding model 'QA'
        db.create_table(u'companies_qa', (
            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('question_date', self.gf('django.db.models.fields.DateTimeField')()),
            ('answer_date', self.gf('django.db.models.fields.DateTimeField')()),
            ('stock', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['basic_info.Stock'])),
            ('question', self.gf('django.db.models.fields.CharField')(max_length=200)),
            ('answer', self.gf('django.db.models.fields.TextField')()),
            ('main_category', self.gf('django.db.models.fields.CharField')(max_length=10)),
            ('sub_category', self.gf('django.db.models.fields.CharField')(max_length=10)),
            ('polarity', self.gf('django.db.models.fields.IntegerField')(default=3)),
        ))
        db.send_create_signal(u'companies', ['QA'])

        # Adding unique constraint on 'QA', fields ['question_date', 'stock', 'question']
        db.create_unique(u'companies_qa', ['question_date', 'stock_id', 'question'])

        # Adding index on 'QA', fields ['answer_date', 'stock']
        db.create_index(u'companies_qa', ['answer_date', 'stock_id'])

        # Adding index on 'QA', fields ['answer_date', 'stock', 'question', 'polarity']
        db.create_index(u'companies_qa', ['answer_date', 'stock_id', 'question', 'polarity'])

        # Adding model 'QAStatisticsResult'
        db.create_table(u'companies_qastatisticsresult', (
            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('category', self.gf('django.db.models.fields.CharField')(max_length=10)),
            ('name', self.gf('django.db.models.fields.CharField')(max_length=20)),
            ('count', self.gf('django.db.models.fields.IntegerField')(default=0, db_index=True)),
            ('positive_count', self.gf('django.db.models.fields.IntegerField')(default=0, db_index=True)),
            ('negative_count', self.gf('django.db.models.fields.IntegerField')(default=0, db_index=True)),
            ('polarity_count', self.gf('django.db.models.fields.IntegerField')(default=0, db_index=True)),
            ('positive_rate', self.gf('django.db.models.fields.FloatField')(default=0, db_index=True)),
            ('negative_rate', self.gf('django.db.models.fields.FloatField')(default=0, db_index=True)),
            ('date', self.gf('django.db.models.fields.DateField')()),
            ('cycle', self.gf('django.db.models.fields.IntegerField')()),
        ))
        db.send_create_signal(u'companies', ['QAStatisticsResult'])

        # Adding unique constraint on 'QAStatisticsResult', fields ['category', 'name', 'date', 'cycle']
        db.create_unique(u'companies_qastatisticsresult', ['category', 'name', 'date', 'cycle'])

        # Adding index on 'QAStatisticsResult', fields ['category', 'name', 'date', 'cycle']
        db.create_index(u'companies_qastatisticsresult', ['category', 'name', 'date', 'cycle'])


    def backwards(self, orm):
        # Removing index on 'QAStatisticsResult', fields ['category', 'name', 'date', 'cycle']
        db.delete_index(u'companies_qastatisticsresult', ['category', 'name', 'date', 'cycle'])

        # Removing unique constraint on 'QAStatisticsResult', fields ['category', 'name', 'date', 'cycle']
        db.delete_unique(u'companies_qastatisticsresult', ['category', 'name', 'date', 'cycle'])

        # Removing index on 'QA', fields ['answer_date', 'stock', 'question', 'polarity']
        db.delete_index(u'companies_qa', ['answer_date', 'stock_id', 'question', 'polarity'])

        # Removing index on 'QA', fields ['answer_date', 'stock']
        db.delete_index(u'companies_qa', ['answer_date', 'stock_id'])

        # Removing unique constraint on 'QA', fields ['question_date', 'stock', 'question']
        db.delete_unique(u'companies_qa', ['question_date', 'stock_id', 'question'])

        # Removing unique constraint on 'DailyMoneyFlowByConcept', fields ['date', 'concept']
        db.delete_unique(u'companies_dailymoneyflowbyconcept', ['date', 'concept_id'])

        # Removing unique constraint on 'DailyMoneyFlowByIndustry', fields ['date', 'industry']
        db.delete_unique(u'companies_dailymoneyflowbyindustry', ['date', 'industry_id'])

        # Removing unique constraint on 'DailyMoneyFlow', fields ['date', 'stock']
        db.delete_unique(u'companies_dailymoneyflow', ['date', 'stock_id'])

        # Removing unique constraint on 'RumorVerification', fields ['date', 'url']
        db.delete_unique(u'companies_rumorverification', ['date', 'url'])

        # Deleting model 'RumorVerification'
        db.delete_table(u'companies_rumorverification')

        # Deleting model 'DailyMoneyFlow'
        db.delete_table(u'companies_dailymoneyflow')

        # Deleting model 'DailyMoneyFlowByIndustry'
        db.delete_table(u'companies_dailymoneyflowbyindustry')

        # Deleting model 'DailyMoneyFlowByConcept'
        db.delete_table(u'companies_dailymoneyflowbyconcept')

        # Deleting model 'QA'
        db.delete_table(u'companies_qa')

        # Deleting model 'QAStatisticsResult'
        db.delete_table(u'companies_qastatisticsresult')


    models = {
        u'basic_info.concept': {
            'Meta': {'object_name': 'Concept'},
            'name': ('django.db.models.fields.CharField', [], {'max_length': '40', 'primary_key': 'True'}),
            'stocks': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['basic_info.Stock']", 'through': u"orm['basic_info.StockConceptMap']", 'symmetrical': 'False'})
        },
        u'basic_info.industry': {
            'Meta': {'object_name': 'Industry'},
            'name': ('django.db.models.fields.CharField', [], {'max_length': '40', 'primary_key': 'True'}),
            'stocks': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['basic_info.Stock']", 'through': u"orm['basic_info.StockIndustryMap']", 'symmetrical': 'False'})
        },
        u'basic_info.stock': {
            'Meta': {'object_name': 'Stock'},
            'code': ('django.db.models.fields.CharField', [], {'max_length': '8', 'primary_key': 'True'}),
            'csrc_industry': ('django.db.models.fields.CharField', [], {'max_length': '40'}),
            'csrc_sub_industry': ('django.db.models.fields.CharField', [], {'max_length': '20'}),
            'full_name': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
            'pinyin_name': ('django.db.models.fields.CharField', [], {'max_length': '20'}),
            'short_name': ('django.db.models.fields.CharField', [], {'max_length': '20', 'db_index': 'True'})
        },
        u'basic_info.stockconceptmap': {
            'Meta': {'object_name': 'StockConceptMap'},
            'concept': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['basic_info.Concept']"}),
            'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'stock': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['basic_info.Stock']"})
        },
        u'basic_info.stockindustrymap': {
            'Meta': {'object_name': 'StockIndustryMap'},
            'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'industry': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['basic_info.Industry']"}),
            'stock': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['basic_info.Stock']"})
        },
        u'companies.dailymoneyflow': {
            'Meta': {'unique_together': "(('date', 'stock'),)", 'object_name': 'DailyMoneyFlow'},
            'big_flow': ('django.db.models.fields.FloatField', [], {}),
            'closed_price': ('django.db.models.fields.FloatField', [], {}),
            'date': ('django.db.models.fields.DateField', [], {'db_index': 'True'}),
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'non_big_flow': ('django.db.models.fields.FloatField', [], {}),
            'stock': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['basic_info.Stock']"}),
            'super_flow': ('django.db.models.fields.FloatField', [], {}),
            'total_flow': ('django.db.models.fields.FloatField', [], {'db_index': 'True'})
        },
        u'companies.dailymoneyflowbyconcept': {
            'Meta': {'unique_together': "(('date', 'concept'),)", 'object_name': 'DailyMoneyFlowByConcept'},
            'concept': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['basic_info.Concept']"}),
            'date': ('django.db.models.fields.DateField', [], {'db_index': 'True'}),
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'total_flow': ('django.db.models.fields.FloatField', [], {'db_index': 'True'})
        },
        u'companies.dailymoneyflowbyindustry': {
            'Meta': {'unique_together': "(('date', 'industry'),)", 'object_name': 'DailyMoneyFlowByIndustry'},
            'date': ('django.db.models.fields.DateField', [], {'db_index': 'True'}),
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'industry': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['basic_info.Industry']"}),
            'total_flow': ('django.db.models.fields.FloatField', [], {'db_index': 'True'})
        },
        u'companies.qa': {
            'Meta': {'unique_together': "(('question_date', 'stock', 'question'),)", 'object_name': 'QA', 'index_together': "[['answer_date', 'stock'], ['answer_date', 'stock', 'question', 'polarity']]"},
            'answer': ('django.db.models.fields.TextField', [], {}),
            'answer_date': ('django.db.models.fields.DateTimeField', [], {}),
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'main_category': ('django.db.models.fields.CharField', [], {'max_length': '10'}),
            'polarity': ('django.db.models.fields.IntegerField', [], {'default': '3'}),
            'question': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
            'question_date': ('django.db.models.fields.DateTimeField', [], {}),
            'stock': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['basic_info.Stock']"}),
            'sub_category': ('django.db.models.fields.CharField', [], {'max_length': '10'})
        },
        u'companies.qastatisticsresult': {
            'Meta': {'unique_together': "(('category', 'name', 'date', 'cycle'),)", 'object_name': 'QAStatisticsResult', 'index_together': "[['category', 'name', 'date', 'cycle']]"},
            'category': ('django.db.models.fields.CharField', [], {'max_length': '10'}),
            'count': ('django.db.models.fields.IntegerField', [], {'default': '0', 'db_index': 'True'}),
            'cycle': ('django.db.models.fields.IntegerField', [], {}),
            'date': ('django.db.models.fields.DateField', [], {}),
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'name': ('django.db.models.fields.CharField', [], {'max_length': '20'}),
            'negative_count': ('django.db.models.fields.IntegerField', [], {'default': '0', 'db_index': 'True'}),
            'negative_rate': ('django.db.models.fields.FloatField', [], {'default': '0', 'db_index': 'True'}),
            'polarity_count': ('django.db.models.fields.IntegerField', [], {'default': '0', 'db_index': 'True'}),
            'positive_count': ('django.db.models.fields.IntegerField', [], {'default': '0', 'db_index': 'True'}),
            'positive_rate': ('django.db.models.fields.FloatField', [], {'default': '0', 'db_index': 'True'})
        },
        u'companies.rumorverification': {
            'Meta': {'unique_together': "(('date', 'url'),)", 'object_name': 'RumorVerification'},
            'answer': ('django.db.models.fields.TextField', [], {}),
            'date': ('django.db.models.fields.DateField', [], {'db_index': 'True'}),
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'question': ('django.db.models.fields.TextField', [], {}),
            'stock': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['basic_info.Stock']"}),
            'url': ('django.db.models.fields.URLField', [], {'max_length': '200'})
        }
    }

    complete_apps = ['companies']